package com.glsc.ngateway.common.base.domain.convert;

import com.glsc.ngateway.common.base.enums.OaFlowLogTypeEnum;

import javax.persistence.AttributeConverter;

public class WorkflowRequestlog_LogType_Converter implements AttributeConverter<OaFlowLogTypeEnum, String> {

    @Override
    public String convertToDatabaseColumn(OaFlowLogTypeEnum attribute) {
        return attribute==null?null:attribute.getValue();
    }

    @Override
    public OaFlowLogTypeEnum convertToEntityAttribute(String dbData) {
        for(OaFlowLogTypeEnum lt: OaFlowLogTypeEnum.values()){
            if(lt.getValue().equals(dbData)) return lt;
        }
        return null;
    }
}
